//
// Created by ct on 2020/10/27.
//

#ifndef NETTOP_NETTOP_H
#define NETTOP_NETTOP_H

#include <thread>
#include <string>
#include <mutex>
#include <map>
#include "name_res.h"
#include "mt_list.h"
#include "addr_t.h"
namespace nettop {
    typedef mt_list<addr_t>		async_addr_list;;
    class name_res{
    public:
        name_res(const name_res&) =delete;
        name_res& operator=(const name_res&) =delete;

    private:
        volatile bool&			exit_;
        async_addr_list			list_;
        std::shared_ptr<std::thread>	thrd_;
        std::mutex			mtx_;
        std::map<addr_t, std::string>	addr_map_;
        void thread_proc(void);
    public:
        name_res(volatile bool& e, bool do_not_resolve);

        std::string to_str(const addr_t& in);

        ~name_res();
    };
} // nettop

#endif //NETTOP_NETTOP_H
